package core;
import java.util.Collection;

import org.json.JSONObject;


public class Location {
	private int x;
	private int y;
	
	public Location(int x,int y) {
		this.x = x;
		this.y = y;
	}
	public int getX() {
		return x;
	}
	public int getY() {
		return y;
	}
	public Location plus(Location l) {
		return new Location(getX()+l.getX(),getY()+l.getY());
	}
	public Location minus(Location l) {
		return new Location(getX()-l.getX(),getY()-l.getY());
	}
	public String toString() {
		return "("+x+","+y+")";
	}
	public JSONObject toJSON() {
		try {
			JSONObject me = new JSONObject();
			me.put("x", x);
			me.put("y", y);
		}
		catch(Exception e) {
			e.printStackTrace();
		}
		return null;
	}
	public static Location fromJSON(JSONObject object) {
		Location ret = null;
		try {
			ret = new Location(object.getInt("x"),object.getInt("y"));
		} catch(Exception e) {
			e.printStackTrace();
		}
		return ret;
	}
}
